package cn.zy.demo.springcloudk8s.webservice.controller;

import cn.zy.demo.springcloudk8s.webservice.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version 1.0 created by zy on 2019/11/15 16:54
 */
@RestController
public class WebServiceController {

    @Autowired
    private AccountService accountService;

    /**
     * 探针检查响应类
     *
     * @return
     */
    @RequestMapping("/health")
    public String health() {
        return "OK";
    }

    /**
     * 远程调用account-service提供的服务
     *
     * @return 多次远程调返回的所有结果.
     */
    @RequestMapping("/account")
    public String account() {

        StringBuilder sbud = new StringBuilder();

        for (int i = 0; i < 10; i++) {
            sbud.append(accountService.getDataFromSpringCloudK8SProvider())
                    .append("<br>");
        }

        return sbud.toString();
    }

}
